<template>
    <div style="margin-top:22px">
        <p>时间<i style="width:14px;display: inline-block;"></i>
            <el-input type="text" v-model="wordInput" placeholder="请输入" style="width:16%"
                @keyup.enter.native="search()"></el-input>
            <el-button type="primary" @click="search()">查询</el-button>
        </p>
        <!--表格内容-->
        <el-table ref="list" :data="tableData" style="width: 100%; margin-bottom: 15px" border
            :header-cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }">
            <el-table-column fixed type="selection"> </el-table-column>
            <el-table-column property="companyName" label="公司名称">
            </el-table-column>
            <el-table-column property="name" label="文档名称"> </el-table-column>
            <el-table-column property="type" label="标准类型"> </el-table-column>
            <el-table-column property="price" label="文档价格(元)"> </el-table-column>
            <el-table-column property="createTime" label="发布时间">
            </el-table-column>
            <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                    <el-button type="primary" size="mini" @click="downLoad(scope.row.url)">下载
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination :page-sizes="pageSizes" :page-size="pageSize" :current-page="pageNum" :total="total"
            @size-change="handleSizeChange" @current-change="handleCurrentChange"
            layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>

    </div>
</template>

<script>
import { getDocument } from "@/api/systemManage/documentManage";
export default {
    name: "Word",
    components: {
    },
    data () {
        return {
            wordInput: '',
            tableData: [],
            pageNum: 1,
            pageSize: 10,
            total: 0,
            pageSizes: [10],
        };
    },
    methods: {
        search () {
            getDocument('qyid=' + this.id + '&input=' + this.text + '&pageNum=' + this.pageNum + '&pageSize=' + this.pageSize).then((res) => {
                this.tableData = res.data.list
                this.total = res.data.total
                this.tabletest()
            })
        },
        handleSizeChange (e) {
            this.pageSize = e
            if (this.input) {
                this.search()
            } else {
                this.getList()
            }

        },
        handleCurrentChange (e) {
            this.pageNum = e
            if (this.input) {
                this.search()
            } else {
                this.getList()
            }
        },
        getList () {
            let params = localStorage.getItem('userId')
            correlationId('userId=' + params).then((res) => {
                this.id = res.data.companyId
                selectAll('qyid=' + this.id + '&pageNum=' + this.pageNum + '&pageSize=' + this.pageSize).then((res) => {
                    this.tableData = res.data.list
                    this.total = res.data.total
                    this.tabletest()
                })
            })
        },
    },
    mounted () {
        this.get();
    },
};
</script>

<style scoped lang="less">
.el-form {
    padding: 0 10px;
}

.el-date-editor {
    width: 100% !important;
}
</style>
